package com.burstly.lib.component.networkcomponent.millennial;

import android.location.Location;
import com.burstly.lib.component.networkcomponent.AbstractNetworkConfigurator;
import com.burstly.lib.conveniencelayer.BurstlyAdSize;
import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.NullSafeHashtable;
import com.burstly.lib.util.Utils;
import com.millennialmedia.android.MMRequest;
import java.util.Hashtable;
import java.util.Map;

class MillennialConfigurator extends AbstractNetworkConfigurator<MMRequest>
  implements LocationValet.ILocationValetListener
{
  public static final String AP_ID = "apID";
  public static final String GOAL_ID = "goalId";
  public static final String IGNORE_DENSITY = "ignoreDensity";
  public static final String LOCATION_ALLOWED = "locationAllowed";
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private Integer mAge;
  private String mAppId;
  private String mChildren;
  private String mEducation;
  private String mEthnicity;
  private String mGender;
  private String mGoalId;
  private int mHeight = 0;
  private boolean mIgnoreDensity;
  private Integer mIncome;
  private boolean mIsInterstitial;
  private String mKeywords;
  private boolean mLocationAllowed;
  private final String mLogTag;
  private String mMartialStatus;
  private String mOrientation;
  private String mPolitics;
  private int mWidth = 0;
  private String mZip;

  MillennialConfigurator(String paramString)
  {
    this.mLogTag = ("Cfg for " + paramString);
  }

  private String getEducationType(String paramString)
  {
    if (paramString == null)
      paramString = "unknown";
    do
    {
      return paramString;
      if (paramString.equalsIgnoreCase("doctor"))
        return "phd";
      if (paramString.equalsIgnoreCase("master"))
        return "masters";
    }
    while ((paramString.equalsIgnoreCase("highschool")) || (paramString.equalsIgnoreCase("someCollege")) || (paramString.equalsIgnoreCase("associate")) || (paramString.equalsIgnoreCase("bachelor")) || (paramString.equalsIgnoreCase("professional")));
    return "unknown";
  }

  private String getEthnicityType(String paramString)
  {
    if (paramString == null)
      paramString = null;
    do
    {
      return paramString;
      if (paramString.equalsIgnoreCase("black"))
        return "afroamerican";
      if (paramString.equalsIgnoreCase("middleEastern"))
        return "middleeastern";
      if (paramString.equalsIgnoreCase("nativeAmerican"))
        return "nativeamerican";
    }
    while ((paramString.equalsIgnoreCase("hispanic")) || (paramString.equalsIgnoreCase("asian")) || (paramString.equalsIgnoreCase("indian")) || (paramString.equalsIgnoreCase("white")));
    if (paramString.equalsIgnoreCase("pacificIslander"))
      return "pacificIslander";
    if ((paramString.equalsIgnoreCase("mixed")) || (paramString.equalsIgnoreCase("other")))
      return "other";
    return null;
  }

  private String getGenderType(String paramString)
  {
    if (paramString == null)
      paramString = "unknown";
    while ((paramString.equalsIgnoreCase("female")) || (paramString.equalsIgnoreCase("male")) || (paramString.equalsIgnoreCase("unknown")))
      return paramString;
    return "unknown";
  }

  private String getMartialStatus(String paramString)
  {
    if (paramString == null)
      paramString = null;
    while ((paramString.equalsIgnoreCase("single")) || (paramString.equalsIgnoreCase("divorced")) || (paramString.equalsIgnoreCase("engaged")) || (paramString.equalsIgnoreCase("relationship")) || (paramString.equalsIgnoreCase("swinger")))
      return paramString;
    return null;
  }

  private void setAdSize(Map<String, ?> paramMap)
  {
    Object localObject = paramMap.get("adSizeCodeValue");
    if (localObject != null)
    {
      BurstlyAdSize localBurstlyAdSize = BurstlyAdSize.parseAdSize((String)localObject);
      if (localBurstlyAdSize != null)
      {
        this.mWidth = localBurstlyAdSize.getWidth();
        this.mHeight = localBurstlyAdSize.getHeight();
      }
    }
    int i = Utils.getIntValue((String)paramMap.get("width"), Integer.valueOf(-1)).intValue();
    int j = Utils.getIntValue((String)paramMap.get("height"), Integer.valueOf(-1)).intValue();
    if (i != -1)
      this.mWidth = i;
    if (j != -1)
      this.mHeight = j;
  }

  private void setInterstitial(Map<String, ?> paramMap)
  {
    Object localObject1 = paramMap.get("isCodeValueInterstitial");
    if (localObject1 != null)
      this.mIsInterstitial = ((Boolean)localObject1).booleanValue();
    Object localObject2 = paramMap.get("isInterstitial");
    if (localObject2 != null)
      if ((!Boolean.parseBoolean((String)localObject2)) && (!"YES".equals((String)localObject2)) && (!"1".equals((String)localObject2)))
        break label81;
    label81: for (boolean bool = true; ; bool = false)
    {
      this.mIsInterstitial = bool;
      return;
    }
  }

  protected void applyClientTargetingParamsToNetwork(Map<String, String> paramMap)
  {
    this.mAge = getAge(Utils.getDateFromString((String)paramMap.get("dateOfBirth"), "dd-MM-yyyy"));
    this.mEducation = getEducationType((String)paramMap.get("educationType"));
    this.mEthnicity = getEthnicityType((String)paramMap.get("ethnicityType"));
    this.mGender = getGenderType((String)paramMap.get("gender"));
    this.mIncome = Utils.getIntValue((String)paramMap.get("income"), null);
    String str = (String)paramMap.get("keyWords");
    if (str != null)
      this.mKeywords = str.replace(' ', ',');
    this.mMartialStatus = getMartialStatus((String)paramMap.get("martial"));
    this.mZip = ((String)paramMap.get("postalCode"));
  }

  public void configure(MMRequest paramMMRequest)
  {
    NullSafeHashtable localNullSafeHashtable = new NullSafeHashtable();
    if (this.mAge != null);
    for (String str1 = this.mAge.toString(); ; str1 = null)
    {
      localNullSafeHashtable.put("age", str1);
      localNullSafeHashtable.put("gender", this.mGender);
      localNullSafeHashtable.put("zip", this.mZip);
      localNullSafeHashtable.put("martial", this.mMartialStatus);
      localNullSafeHashtable.put("orientation", this.mOrientation);
      localNullSafeHashtable.put("ethnicity", this.mEthnicity);
      Integer localInteger = this.mIncome;
      String str2 = null;
      if (localInteger != null)
        str2 = this.mIncome.toString();
      localNullSafeHashtable.put("income", str2);
      localNullSafeHashtable.put("keywords", this.mKeywords);
      localNullSafeHashtable.put("children", this.mChildren);
      localNullSafeHashtable.put("politics", this.mPolitics);
      localNullSafeHashtable.put("education", this.mEducation);
      paramMMRequest.setMetaValues(localNullSafeHashtable);
      return;
    }
  }

  String getAppId()
  {
    return this.mAppId;
  }

  String getGoalId()
  {
    return this.mGoalId;
  }

  int getHeight()
  {
    return this.mHeight;
  }

  int getWidth()
  {
    return this.mWidth;
  }

  boolean isIgnoreDensity()
  {
    return this.mIgnoreDensity;
  }

  boolean isInterstitial()
  {
    return this.mIsInterstitial;
  }

  boolean isLocationAllowed()
  {
    return this.mLocationAllowed;
  }

  public void onBetterLocationFound(Location paramLocation)
  {
    MMRequest.setUserLocation(paramLocation);
  }

  public void readParameters(Map<String, ?> paramMap)
    throws IllegalArgumentException
  {
    applyClientTargetingIfAllowed(paramMap);
    this.mAppId = ((String)paramMap.get("apID"));
    Utils.checkNotNull(this.mAppId, "apID can not be null");
    LoggerExt localLoggerExt = LOG;
    String str1 = this.mLogTag;
    Object[] arrayOfObject = new Object[1];
    arrayOfObject[0] = this.mAppId;
    localLoggerExt.logInfo(str1, "apID for Millennial: {0}", arrayOfObject);
    this.mGoalId = ((String)paramMap.get("goalId"));
    this.mIgnoreDensity = Boolean.parseBoolean((String)paramMap.get("ignoreDensity"));
    setInterstitial(paramMap);
    setAdSize(paramMap);
    this.mLocationAllowed = Boolean.parseBoolean((String)paramMap.get("locationAllowed"));
    Object localObject1 = paramMap.get("age");
    Integer localInteger1;
    String str2;
    label176: Integer localInteger2;
    label204: String str3;
    label233: String str4;
    label262: String str5;
    label291: String str6;
    label336: Object localObject8;
    if (localObject1 != null)
    {
      localInteger1 = (Integer)localObject1;
      this.mAge = localInteger1;
      Object localObject2 = paramMap.get("gender");
      if (localObject2 == null)
        break label413;
      str2 = (String)localObject2;
      this.mGender = str2;
      Object localObject3 = paramMap.get("income");
      if (localObject3 == null)
        break label422;
      localInteger2 = (Integer)localObject3;
      this.mIncome = localInteger2;
      Object localObject4 = paramMap.get("zip");
      if (localObject4 == null)
        break label431;
      str3 = (String)localObject4;
      this.mZip = str3;
      Object localObject5 = paramMap.get("martial");
      if (localObject5 == null)
        break label440;
      str4 = (String)localObject5;
      this.mMartialStatus = str4;
      Object localObject6 = paramMap.get("ethnicity");
      if (localObject6 == null)
        break label449;
      str5 = (String)localObject6;
      this.mEthnicity = str5;
      this.mOrientation = ((String)paramMap.get("orientation"));
      Object localObject7 = paramMap.get("keywords");
      if (localObject7 == null)
        break label458;
      str6 = (String)localObject7;
      this.mKeywords = str6;
      this.mChildren = ((String)paramMap.get("children"));
      this.mPolitics = ((String)paramMap.get("politics"));
      localObject8 = paramMap.get("education");
      if (localObject8 == null)
        break label467;
    }
    label413: label422: label431: label440: label449: label458: label467: for (String str7 = (String)localObject8; ; str7 = this.mEducation)
    {
      this.mEducation = str7;
      return;
      localInteger1 = this.mAge;
      break;
      str2 = this.mGender;
      break label176;
      localInteger2 = this.mIncome;
      break label204;
      str3 = this.mZip;
      break label233;
      str4 = this.mMartialStatus;
      break label262;
      str5 = this.mEthnicity;
      break label291;
      str6 = this.mKeywords;
      break label336;
    }
  }

  void setIsInterstitial(boolean paramBoolean)
  {
    this.mIsInterstitial = paramBoolean;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.millennial.MillennialConfigurator
 * JD-Core Version:    0.6.2
 */